<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>体验金</title>
    <link rel="stylesheet" type="text/css" href="./css/api.css" />
    <link rel="stylesheet" type="text/css" href="./css/aui.css" />
    <link rel="stylesheet" type="text/css" href="./css/font-awesome.min.css" />
    <link rel="stylesheet" type="text/css" href="./css/styleold.css" />
    <script type="text/javascript" src="./script/api.js"></script>
    <script type="text/javascript" src="./script/aui-tab.js"></script>
    <link rel="stylesheet" type="text/css" href="./css/aui-slide.css" />
    <script type="text/javascript" src="./script/aui-slide.js"></script>
    <script type="text/javascript" src="./script/base.js"></script>
    <script type="text/javascript">
        function closeWin() {

            api.closeWin({});
        };
    </script>
</head>

<body>
    <!-- 头部 -->
    <header class="aui-bar aui-bar-nav pos">
        <a class="aui-pull-left aui-btn" onclick="closeWin()">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title">体验金</div>
    </header>
    <div class="header-d"></div>
    <style>
        body {
            background: #ffba31;
        }
    </style>
    <!-- 体验金    -->
    <div class="tiyanjin">
        <img src="image/tiyanjin-bg.png">
        <a id="btn_1"><img src="image/tiyanjin-btn.png" tapmode onclick="tiyanjin_detail()"></a>
        <a id="btn_2" style="display: none"><img src="image/tiyanjin-btn-2.png"></a>
    </div>
</body>

<script type="text/javascript">
    apiready = function() {
        var userid = $api.getStorage('userid');
        if (userid) {
            api.ajax({
                url: webAddress + '/index.php?ctl=app_user_center&act=is_learn',
                method: 'post',
                data: {
                    values: {
                        id: userid
                    },
                }
            }, function(ret, err) {

                if (ret) {
                    var count = ret.count;
                    if (count == '0') {
                        var btn_1 = document.getElementById("btn_1");
                        btn_1.style.display = '';
                        var btn_2 = document.getElementById("btn_2");
                        btn_2.style.display = 'none';
                    } else {
                        var btn_1 = document.getElementById("btn_1");
                        btn_1.style.display = 'none';
                        var btn_2 = document.getElementById("btn_2");
                        btn_2.style.display = '';
                    }
                } else {
                    alert(err.msg);
                }
            });
        }


    }

    function tiyanjin_detail() {
        var delay = 0;
        if (api.systemType != 'ios') {
            // delay = 300;
        }
        var userid = $api.getStorage('userid');
        if (!userid) {
            alert('请先登录');
            api.openWin({
                name: 'login',
                url: './login.html',
                pageParam: {
                    login: 'tiyanjin'
                }
            });
            return false;
        }

        api.ajax({
            url: webAddress + '/index.php?ctl=app_user_center&act=get_learn',
            method: 'post',
            data: {
                values: {
                    id: userid
                },
            }
        }, function(ret, err) {
            if (ret) {
                if (ret.status == 0) {
                    alert(ret.info);
                    return false;
                } else {
                    // var gotoUser = 'gotoUser();';
                    // api.execScript({
                    //     name: 'home',
                    //     script: gotoUser,
                    // });
                    // api.closeToWin({
                    //     name: 'home'
                    // });
                    var setSele = 'randomSwitchBtn(2);';
                    api.execScript({
                        name: 'root',
                        script: setSele,
                    });
                    api.closeToWin({
                        name: 'root'
                    });
                }
            } else {
                alert(JSON.stringify(err));
            }
        });

    };
</script>

</html>
